import { User } from 'oidc-client-ts'
import UserManagerAD from '~/auth/auth'

interface IState {
  userManager: UserManagerAD
  user: User | null
}

export const useUserManagerStore = defineStore('userManagerStore', {
  state: () =>
    ({
      userManager: new UserManagerAD(),
      user: null
    } as IState),
  actions: {
    async getUser() {
      const user = await this.userManager.getUser()
      this.user = user
    }
  }
})
